package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.model.wemedia.pojos.WmUser;
import com.heima.wemedia.service.WmMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController {

    @Autowired
    public WmMaterialService wmMaterialService;

    @PostMapping("/upload_picture")
    public ResponseResult upload(MultipartFile multipartFile) {

        return wmMaterialService.upload(multipartFile);
    }

    @PostMapping("/list")
    public ResponseResult findList(@RequestBody WmMaterialDto wmMaterialDto) {

        return wmMaterialService.findList(wmMaterialDto);
    }

    /**
     * 收藏
     * @param id
     * @return
     */
    @GetMapping("/collect/{id}")
    public ResponseResult cancelCollect(@PathVariable Integer id) {
        return wmMaterialService.updateCollect(id);
    }
    @GetMapping("/cancel_collect/{id}")
    public ResponseResult Collect(@PathVariable Integer id) {
        return wmMaterialService.updateCollect(id);
    }
}
